package com.awonsome.mall.pms.api;

import com.awonsome.common.core.result.Result;
import com.awonsome.mall.pms.pojo.dto.app.LockStockDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 库存管理
 *
 * @author yangdejun
 * @date 2022/1/17 20:07
 */
@FeignClient(value = "mall-pms", contextId = "stock")
public interface StockFeignClient {

    /**
     * 锁定库存
     *
     * @return
     */
    @PutMapping(value = "/app-api/v1/stocks/_lock")
    Result lockStock(@RequestBody List<LockStockDTO> list);

    /**
     * 解锁库存
     *
     * @param orderToken
     * @return
     */
    @PutMapping(value = "/app-api/v1/stocks/_unlock")
    Result<Boolean> unlockStock(@RequestParam String orderToken);

    /**
     * 扣减库存
     * @param orderToken
     * @return
     */
    @PutMapping(value = "/app-api/v1/stocks/_deduct")
    Result deductStock(@RequestParam String orderToken);

}
